import os

print('Process (%s) start...' % os.getpid())
# Only works on Unix/Linux/macOS:
pid = os.fork()
if pid == 0:
    print('I am child process (%s) and my parent is %s.' % (os.getpid(), os.getppid()))
else:
    print('I (%s) just created a child process (%s).' % (os.getpid(), pid))

# python中对进程的抽象
from multiprocessing import Process
import os
print("==================================================================")
# 子进程要执行的代码
# def run_proc(name):
#     print('Run child process %s (%s)...' % (name, os.getpid()))

# if __name__=='__main__':
#     print('Parent process %s.' % os.getpid())
#     p = Process(target=run_proc, args=('test',))
#     print('Child process will start.')
#     p.start()
#     p.join()
#     print('Child process end.')

print("==================================================================")

def P(text):
    print(text)
if __name__ == '__main__':
    type(os.getpid())
    print("parent process: %d" % os.getpid())
    # 传递任务和参数
    child = Process(target=P,args=("aaaaaaaaa",))

    child.start()
    child.join()
    
print("===============================Pool===================================")
from multiprocessing import Pool
import os,time,random

